package com.ithaima.collectiondemo;

import java.util.ArrayList;
import java.util.Collection;

public class MyCollectonDemo2 {
    /*
    boolean add(E e)添加元素
    boolean remove(Object o)从集合中移除指定的元素
    boolean removeIf(Object o)根据条件进行移除
    void   clear()清空集合中的元素
    boolean contains(Object o)判断集合中是否存在指定的元素
    boolean isEmpty()判断集合是否为空int
    size()集合的长度，也就是集合中元素的个数
     */
    public static void main(String[] args) {
        Collection<String> list = new ArrayList<>();
        list.add("qqq");
        list.add("www");
        list.add("eee");
        list.add("qqqq");

        boolean b = list.remove("qqq");
        System.out.println(b);

        list.removeIf((String s) -> {
            return s.length() == 4;
        });

        System.out.println(list);

        boolean b1 = list.contains("www");
        System.out.println(b1);

        int size = list.size();
        System.out.println(size);

        boolean b2 = list.isEmpty();
        System.out.println(b2);

        list.clear();

        boolean b3 = list.isEmpty();
        System.out.println(b3);
    }
}
